﻿<%@ Page Title="" Language="C#" MasterPageFile="/Common/Master.master" %>

<script runat="server">

</script>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentForm" runat="Server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentHtml" runat="Server">
    <div class="easyui-layout tableEdit" data-options="fit:true,border:false">
        <div data-options="region:'center',border:false" id="validation" class="validationEngineContainer">
            <div class="z_wrap">
                <ul class="info">
                    <li>
                        <em class='l_name'>名称：</em>
                        <div class='r_con1'>
                            <input id='name' name='Name' type='text' class='validate[required]' data-prompt-position='bottomRight' />
                        </div>
                    </li>
                    <li>
                        <em class='l_name'>创建时间：</em>
                        <div id='addtime' class='r_con1'>自动</div>
                    </li>
                </ul>
            </div>
        </div>
        <div data-options="region:'south'" style="height: 35px; border-bottom: 0px; border-left: 0px; border-right: 0px;" class="edit_bottom">
            <a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-save'" id="buttonOk">确 定</a>
            <a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" onclick="$.layerClose(false);">取 消</a>
        </div>
    </div>

    <script type="text/javascript">
        $(function () {
            jQuery('#validation').validationEngine();

            $("#buttonOk").click(function () {
                InsertOrUpdate();
            });
            if ($.getUrlParamer("guid") != "") {
                DataBind();
            }
        });

        function DataBind() {
            $.InvokeAjax({
                url: "system_role/GetById",
                data: { id: $.getUrlParamer("guid") },
                callBack: function (result) {
                    var obj = result.Data;

                    $.SetValue("id", obj.id);
                    $.SetValue("name", obj.name);
                    $.SetValue("addtime", $.DateFormat(obj.addtime, 'yyyy-MM-dd HH:mm:ss'));

                }
            });
        }

        function InsertOrUpdate() {
            if (!$('#validation').validationEngine('validate')) { return false; }
            var url = "";
            var obj = {};

            if ($.getUrlParamer("guid") != "") {
                url = "system_role/Update";
                var obj = { id: $.getUrlParamer("guid") };
                obj.name = $.GetValue("name");
                obj.addtime = $.JsonDateFy($.GetValue("addtime") == "自动" ? $.GetDateTime() : $.GetValue("addtime"));
            }
            else {
                url = "system_role/Insert";
                obj.name = $.GetValue("name");
            }


            $.InvokeAjax({
                url: url,
                data: obj,
                callBack: function (data) {
                    $.layerClose(true);
                }
            });
        }
    </script>
</asp:Content>
